package com.example.test0520.activity;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

import com.example.test0520.R;
import com.example.test0520.util.StringUtils;
import com.example.test0520.util.User;

import org.litepal.LitePal;
import org.litepal.crud.LitePalSupport;

import java.util.List;

public class RegisterActivity extends BaseActivity {

    private Button rsBtn;
    private EditText rsUser;
    private EditText rsPass;
    private User user;

    @Override
    protected int initLayout() {
        return R.layout.activity_register;
    }

    @Override
    protected void initView() {
        rsBtn = findViewById(R.id.rs_btn);
        rsUser = findViewById(R.id.rs_user);
        rsPass = findViewById(R.id.rs_pass);
    }

    @Override
    protected void initData() {
//        getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
        getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION);
        rsBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String username = rsUser.getText().toString().trim();
                String password = rsPass.getText().toString().trim();
                if (StringUtils.isEmpty(username)) {
                    showToast("请输入账号");
                    return;
                } else if (StringUtils.isEmpty(password)) {
                    showToast("请输入密码");
                    return;
                }
                user = new User();
                user.setUsername(username);
                user.setPassword(password);
                user.save();
                showToast("注册成功");
            }
        });
    }
}
